#include <opencv2/opencv.hpp>
#include <string>

using namespace cv;
using namespace std;

int main(int argc, char** argv)
{
	if(argc != 4){
		cout << "Usage: IMAGE_NAME FLIP_CODE SAVE_NAME" << endl;
		return -1;
	}
	cv::Mat img = cv::imread(argv[1]);
	cv::Mat res;
	int flip_code;
	sscanf(argv[2],"%d",&flip_code);
	//cout << "flip code " << flip_code << endl;
	cv::flip(img,res,flip_code);
	//cv::imshow("res",res);
	//cv::imshow("img",img);
	//cv::waitKey();
	stringstream ss; ss << flip_code;
	cv::imwrite(string(argv[3]),res);
	return 0;
}